const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path')
const url = 'http://qup.gateway.itdev.quanyou.com.cn'

module.exports = merge(common, {
  entry: './src/main.js',
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    },
    extensions: ['*', '.js', '.vue', '.json']
  },
  devServer: {
    port: 8091,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '/auth': {
        target: url,
        changeOrigin: true,
        pathRewrite: {
          '^/auth': '/auth'
        }
      },
      /* '/ucenter/api': {
        target: url,
        changeOrigin: true,
        pathRewrite: {
          '^/ucenter/api': '/ucenter/api/v1'
        }
      }, */
      
      '/ucenter/api': {
        target: 'https://qup2dev.quanyou.com.cn/ucenter',
        // target: 'http://192.168.99.109:4002', // xieshijie地址
        // target: 'http://192.168.99.50:4002', // yuxiaodong地址
        changeOrigin: true,
        pathRewrite: {
          '^/ucenter/api': '/api'
        }
      },
      '/mcenter/api': {
        target: 'https://qup2dev.quanyou.com.cn/mcenter',
        // target: 'http://192.168.99.109:4002', // xieshijie地址
        // target: 'http://192.168.99.50:4002', // yuxiaodong地址
        changeOrigin: true,
        pathRewrite: {
          '^/mcenter/api': '/api'
        }
      },
      '/select-service/api': {
        target: 'http://select-service.itdev2.quanyou.com.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/select-service/api': '/api'
        }
      },
      '/data-dict/api': {
        target: ' https://qup2dev.quanyou.com.cn/data-dict',
        changeOrigin: true,
        pathRewrite: {
          '^/data-dict/api': '/api'
        }
      },
      '/code': {
        target: url,
        changeOrigin: true,
        pathRewrite: {
          '^/code': '/code'
        }
      },
      '/gen': {
        target: url,
        changeOrigin: true,
        pathRewrite: {
          '^/gen': '/gen'
        }
      },
      '/v1': {
        target: 'http://172.18.158.50:4002',
        changeOrigin: true
      },
      '/bag-checkin/api': {
        // target: 'http://192.168.99.91:7001',
        target: 'https://qupdev.quanyou.com.cn/bag-checkin',
        changeOrigin: true,
        pathRewrite: {
          '^/bag-checkin/api': '/api'
        }
      },
      '/price-center/api': {
        target: 'https://uacdev.quanyou.com.cn/price-center',
        changeOrigin: true,
        pathRewrite: {
          '^/price-center/api': '/api'
        }
      },
      '/po-center/api': {
        target: 'https://uacdev.quanyou.com.cn/po-center',
        changeOrigin: true,
        pathRewrite: {
          '^/po-center/api': '/api'
        }
      },
      '/ec-order-service/api': {
        target: 'http://ec-order-service.itdev2.quanyou.com.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/ec-order-service/api': '/api'
        }
      },
      '/ec-report-service/api': {
        target: 'http://ec-report-service.itdev2.quanyou.com.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/ec-report-service/api': '/api'
        }
      },
      '/call-center/api': {
        target: 'http://call-center-api.itdev2.quanyou.com.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/call-center/api': '/api'
        }
      },
      '/mdm-admin/api': {
        target: 'http://mdm-admin.itdev2.quanyou.com.cn',
        // target: 'http://192.168.99.104:8558/',
        changeOrigin: true,
        pathRewrite: {
          '^/mdm-admin/api': '/api'
        }
      }
    },
    // after: require('./mock/mock-server.js')
  },
  devtool: 'inline-source-map'
})
